home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Enigma Amiga Life 109
/
EnigmaAmiga109CD.iso
/
dalla rivista
/
amiga.free
/
sorgenti vari
/
wolfedit2 2.0.4 source.sit
/
WolfEdit2 2.0.4 Source
/
UEditEnemies.p
< prev
next >
Wrap
Text File
|
1996-04-03
|
6KB
|
240 lines
unit UEditEnemies;
interface
uses
UWolfDoc;
procedure IUEditEnemies;
procedure EditEnemies (mapList: TMapListDoc);
implementation
uses
UEditArt;
const
enemyEditDlogID = 138;
paletteItem = 2;
imageItem = 3;
frameMenuItem = 5;
prevFrameItem = 7;
nextFrameItem = 8;
animRsrcID = 128;
frameMenuID = 143;
type
AnimHandle = ^AnimPtr;
AnimPtr = ^AnimRecord;
AnimRecord = record
numEntries: integer;
entries: array[0..99] of record
objectCode: integer;
firstBrgrID: integer;
frameMenu: integer;
end;
end;
TEnemyImagePalette = object(TImagePalette)
procedure IEnemyImagePalette;
procedure DrawImage (itemNo: integer; r: Rect);
override;
function ItemSelectable (item: integer): boolean;
override;
end;
TEnemyEditDialog = object(TArtEditDialog)
fCurrentFrame: integer;
procedure IEnemyEditDialog (itsMapList: TMapListDoc);
procedure UninstallArt;
override;
procedure InstallArt;
override;
procedure TEnemyEditDialog.UninstallFrame;
procedure TEnemyEditDialog.InstallFrame;
function TEnemyEditDialog.CurrentObjectCode: integer;
function TEnemyEditDialog.CurrentFrameBrgrID: integer;
procedure TEnemyEditDialog.GoToFrame (i: integer);
procedure TEnemyEditDialog.SetUpFrameButtons;
procedure TEnemyEditDialog.ItemHit (var e: EventInfo; itemNo: integer);
override;
function ArtImageType: CustomImageType;
override;
function ArtImageCode: integer;
override;
procedure ChangeImage (gworld: GWorldPtr; isThumbnail: boolean);
override;
end;
var
gAnims: AnimHandle;
function ObjectCode (itemNo: integer): integer;
begin
ObjectCode := gAnims^^.entries[itemNo].objectCode;
end;
procedure TEnemyImagePalette.IEnemyImagePalette;
begin
IImagePalette(16, gAnims^^.numEntries);
fDialog := nil;
end;
procedure TEnemyImagePalette.DrawImage (itemNo: integer; r: Rect);
var
n: integer;
begin
fDialog.fMapList.PlotObject(ObjectCode(itemNo), 0, r);
end;
function TEnemyImagePalette.ItemSelectable (item: integer): boolean;
begin
ItemSelectable := fDialog.fMapList.ObjectAvailable(ObjectCode(item));
end;
procedure TEnemyEditDialog.IEnemyEditDialog (itsMapList: TMapListDoc);
var
palette: TEnemyImagePalette;
begin
new(palette);
palette.IEnemyImagePalette;
IArtEditDialog(enemyEditDlogID, palette, itsMapList, true);
palette.fDialog := self;
fCurrentFrame := 0;
SetDismissItems([ok]);
end;
procedure TEnemyEditDialog.UninstallArt;
begin
UninstallFrame;
end;
procedure TEnemyEditDialog.InstallArt;
type
MenuHandleHandle = ^MenuHandlePtr;
MenuHandlePtr = ^MenuHandle;
var
iHandle, newCtl: ControlHandle;
iType: integer;
iRect: Rect;
begin
GetItem(frameMenuItem, iType, Handle(iHandle), iRect);
iRect := iHandle^^.contrlRect;
newCtl := NewCtrl(nil, iRect, iHandle^^.contrlTitle, false, 1, gAnims^^.entries[fCurrentArt].frameMenu, 62, 1008);
DisposeCtrl(iHandle);
SetItem(frameMenuItem, iType, Handle(newCtl), iRect);
ShowControl(newCtl);
ValidateRect(iRect);
fCurrentFrame := 0;
SetUpFrameButtons;
InstallFrame;
end;
procedure TEnemyEditDialog.UninstallFrame;
begin
if (fCurrentArt >= 0) & (fArtView.fChanged) then begin
fMapList.InstallObjectArt(CurrentFrameBrgrID, fArtView.ExtractObject);
fArtView.fChanged := false;
end;
end;
procedure TEnemyEditDialog.InstallFrame;
begin
if fCurrentArt >= 0 then
fArtView.InstallObject(fMapList.GetObjectArt(CurrentFrameBrgrID));
end;
function TEnemyEditDialog.CurrentObjectCode: integer;
begin
CurrentObjectCode := ObjectCode(fCurrentArt);
end;
function TEnemyEditDialog.CurrentFrameBrgrID: integer;
begin
CurrentFrameBrgrID := gAnims^^.entries[fCurrentArt].firstBrgrID + fCurrentFrame;
end;
procedure TEnemyEditDialog.GoToFrame (i: integer);
var
lo, hi: integer;
begin
if i - 1 <> fCurrentFrame then begin
GetItemMinMax(frameMenuItem, lo, hi);
if (lo <= i) & (i <= hi) then begin
UninstallFrame;
fCurrentFrame := i - 1;
SetItemValue(frameMenuItem, i);
SetUpFrameButtons;
InstallFrame;
end;
end;
end;
procedure TEnemyEditDialog.SetUpFrameButtons;
var
i, lo, hi: integer;
begin
GetItemMinMax(frameMenuItem, lo, hi);
i := GetItemValue(frameMenuItem);
EnableItem(prevFrameItem, i > lo);
EnableItem(nextFrameItem, i < hi);
end;
procedure TEnemyEditDialog.ItemHit (var e: EventInfo; itemNo: integer);
begin
inherited ItemHit(e, itemNo);
case itemNo of
frameMenuItem:
GoToFrame(GetItemValue(frameMenuItem));
prevFrameItem:
GoToFrame(GetItemValue(frameMenuItem) - 1);
nextFrameItem:
GoToFrame(GetItemValue(frameMenuItem) + 1);
otherwise
;
end;
end;
function TEnemyEditDialog.ArtImageType: CustomImageType;
begin
ArtImageType := objectImage;
end;
function TEnemyEditDialog.ArtImageCode: integer;
begin
ArtImageCode := CurrentObjectCode;
end;
procedure TEnemyEditDialog.ChangeImage (gworld: GWorldPtr; isThumbnail: boolean);
begin
if isThumbNail or (fCurrentFrame = 0) then
ChangeObjectImage(ArtImageCode, gworld);
end;
procedure EditEnemies (mapList: TMapListDoc);
var
dlog: TEnemyEditDialog;
procedure CheckWindow (win: TWindow);
begin
if member(win, TEnemyEditDialog) then begin
win.Select;
exit(EditEnemies);
end;
end;
begin
mapList.EachWindowDo(CheckWindow);
new(dlog);
dlog.IEnemyEditDialog(mapList);
dlog.Show;
end;
procedure IUEditEnemies;
begin
gAnims := AnimHandle(GetResource('ANIM', animRsrcID));
end;
end.